$(function() {
    $('.skin-minimal input').iCheck({
        checkboxClass: 'icheckbox-blue',
        radioClass: 'iradio-blue',
        increaseArea: '20%'
    });

    $("#form-admin-update").validate({
        rules: {
            userName: {
                required: true,
                minlength: 2,
                maxlength: 10
            },
            password: {
                required: true,
                minlength: 3,
                maxlength: 16
            },
            password2: {
                required: true,
                minlength: 3,
                maxlength: 16,
                equalTo: "#password"
            },
            sex: {
                required: true,
            },
            // phoneNumber: {
            //     required: true,
            //     isPhone: true,
            // },
            // email: {
            //     required: true,
            //     email: true,
            // },
        },
        onkeyup: false,
        focusCleanup: true,
        success: "valid",
        submitHandler:function(form){
            var userName = $("#userName").val();
            if($.trim(userName) == ""){
                layer.msg("输入不能都为空格",{icon:2,time:4000});
                return;
            }
            $.ajax({
                type: "POST",
                // async: false,
                url: '/admin/updateAdminByUserId',
                data: $('#form-admin-update').serialize(),
                success: function (data) {
                    var data = eval("(" + data + ")");
                    if (data.success == true) {
                        layer.msg(data.msg,{icon:1,time:2000},function(){
                            parent.location.reload();
                        });
                    } else if(data.success == false){
                        layer.msg(data.msg,{icon:2,time:4000});
                        return;
                    }
                }
            });
        }
    });
});